package com.zx.controller.user;

import com.zx.config.conversion.StringToDateConversion;
import com.zx.dto.request.user.UserDtoReq;
import com.zx.model.user.User;
import com.zx.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;


@Controller
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;
    /*用户登录*/
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    @ResponseBody
    public User login(UserDtoReq userDtoReq, HttpServletResponse response,HttpServletRequest request) {
        System.out.println(request.getRequestURI());
        return userService.login(userDtoReq,response);
    }
    /*查询用户名*/
    @RequestMapping("/queryName")
    @ResponseBody
    public User queryName(@CookieValue(value = "UserToken") String userToken){
        return userService.queryUser(userToken);
    }
    @PostMapping("/update/user")
    @ResponseBody
    public boolean updatUser(UserDtoReq userDtoReq,@CookieValue(value = "UserToken") String userToken){
       return  userService.updataUser(userDtoReq,userToken);
    }


}
